@use 'sass:color';
@use './var.scss' as *;

// 重置样式
html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system,
  BlinkMacSystemFont,
  "Segoe UI",
  "Noto Sans",
  Helvetica,
  Arial,
  "Microsoft YaHei",
  "Heiti SC",
  SimHei,
  sans-serif,
  "Apple Color Emoji",
  "Segoe UI Emoji";

  @include useTheme {
    background: getVar('background-color');
    font-size: getVar('font-size-base');
    color: getVar('text-color');
  }
}

textarea {
  font-family: -apple-system,
  BlinkMacSystemFont,
  "Segoe UI",
  "Noto Sans",
  Helvetica,
  Arial,
  "Microsoft YaHei",
  "Heiti SC",
  SimHei,
  sans-serif,
  "Apple Color Emoji",
  "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.el-menu.el-menu--horizontal {
  @include useTheme {
    border-bottom: solid 1px getVar('border-color-base');
  }
}

.el-button--medium,
.el-button--small,
.el-button--mini {
  @include useTheme {
    border-radius: getVar('border-radius-base');
  }
}

.el-button {

  @include useTheme {

    &.el-button--text {
      color: getVar('title-color');

      &:hover,
      &:focus {
        color: getVar('primary-color');
      }

      &:active {
        color: color.adjust($color: getVar('primary-color'), $lightness: -12%);
      }
    }

    &.el-button--default {
      color: getVar('text-color');
      background-color: transparent;
      border-radius: getVar('border-radius-base');
      border-color: getVar('border-color-base');

      &:hover,
      &:focus {
        color: getVar('primary-color');
        border-color: getVar('primary-color');
        background-color: transparent;
      }

      &:active {
        color: color.adjust($color: getVar('primary-color'), $lightness: -12%);
        border-color: color.adjust($color: getVar('primary-color'), $lightness: -12%);
        background-color: transparent;
      }
    }

    $button-colors: (
            primary: getVar('primary-color'),
            success: getVar('success-color'),
            warning: getVar('warning-color'),
            danger: getVar('error-color'),
            info: getVar('primary-color'),
    );

    @each $key, $value in $button-colors {
      &.el-button--#{$key} {
        color: white;
        background-color: $value;
        border-color: $value;
        border-radius: getVar('border-radius-base');

        &:hover,
        &:focus {
          color: white;
          border-color: coloren($color: $value, $amount: 8%);
          background-color: coloren($color: $value, $amount: 8%);
        }

        &:active {
          color: white;
          border-color: color.adjust($color: $value, $lightness: -10%);
          background-color: color.adjust($color: $value, $lightness: -10%);
        }
      }
    }
  }
}

.el-popper {

  .popper__arrow {
    display: none;
  }

  @include useTheme {
    color: getVar('text-color');

    .el-dropdown-menu__item:focus,
    .el-dropdown-menu__item:not(.is-disabled):hover {
      background-color: coloren($color: getVar('primary-color'), $amount: 45%);
      color: getVar('primary-color');
    }
  }
}

.el-dropdown-menu {
  @include useTheme {
    border-radius: getVar('border-radius-base');
    background-color: getVar('card-background-color');
    border: 1px solid getVar('border-color-base');
  }
}

.el-dropdown-menu__item {
  @include useTheme {
    color: getVar('title-color');
  }
}

.el-select-group__title {
  @include useTheme {
    color: getVar('text-color');
  }
}

.el-select-dropdown {
  @include useTheme {
    border-radius: getVar('border-radius-base');
    border: 1px solid getVar('border-color-base');
  }
}

.el-select-dropdown__wrap {
  &.el-scrollbar__wrap {
    &::-webkit-scrollbar {
      width: 15px;
      height: 15px;
    }
  }
}

.el-select-group__wrap:not(:last-of-type)::after {
  @include useTheme {
    background: getVar('border-color-base');
  }
}

.el-select-dropdown__item.hover,
.el-select-dropdown__item:hover {
  @include useTheme {
    background-color: coloren($color: getVar('primary-color'), $amount: 45%);
  }
}

.el-select-dropdown__item {
  @include useTheme {
    color: getVar('title-color');
  }
}

.el-select-dropdown__item.selected {

  font-weight: bold;

  @include useTheme {
    color: getVar('primary-color');
  }
}

.el-table {

  @include useTheme {
    color: getVar('text-color');
  }

  thead {
    @include useTheme {
      color: getVar('title-color');
    }
  }

  th.el-table__cell {
    @include useTheme {
      background-color: getVar('title-background-color');
    }
  }
}

.el-table,
.el-table__expanded-cell {
  @include useTheme {
    background-color: getVar('card-background-color');
  }
}

.el-table tr {
  @include useTheme {
    background-color: getVar('card-background-color');
  }
}

.el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
  @include useTheme {
    background-color: getVar('background-color');
  }
}

.el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell {
  @include useTheme {
    background-color: getVar('hover-background-color');
  }
}

.el-table__body tr.hover-row.current-row > td.el-table__cell,
.el-table__body tr.hover-row.el-table__row--striped.current-row > td.el-table__cell,
.el-table__body tr.hover-row.el-table__row--striped.selection-row > td.el-table__cell,
.el-table__body tr.hover-row.el-table__row--striped > td.el-table__cell,
.el-table__body tr.hover-row.selection-row > td.el-table__cell,
.el-table__body tr.hover-row > td.el-table__cell {
  @include useTheme {
    background-color: getVar('hover-background-color');
  }
}

.el-table--border,
.el-table--group {
  @include useTheme {
    border-top: 0px solid getVar('border-color-base');
    border-bottom: 1px solid getVar('border-color-base');
    border-left: 0px solid getVar('border-color-base');
    border-right: 1px solid getVar('border-color-base');
  }
}

.el-table td.el-table__cell,
.el-table th.el-table__cell.is-leaf {
  @include useTheme {
    border-top: 1px solid getVar('border-color-base');
    border-bottom: 0px solid getVar('border-color-base');
    border-left: 1px solid getVar('border-color-base');
    border-right: 1px solid getVar('border-color-base');
  }
}

.el-table__empty-block {
  @include useTheme {
    border-top: 1px solid getVar('border-color-base');
    border-bottom: 0px solid getVar('border-color-base');
    border-left: 1px solid getVar('border-color-base');
    border-right: 0px solid getVar('border-color-base');
  }
}

.el-table--border th.el-table__cell,
.el-table__fixed-right-patch {
  @include useTheme {
    border-top: 1px solid getVar('border-color-base');
    border-bottom: 1px solid getVar('border-color-base');
  }
}

.el-table--border .el-table__cell,
.el-table__body-wrapper .el-table--border.is-scrolling-left ~ .el-table__fixed {
  @include useTheme {
    border-right: 1px solid getVar('border-color-base');
  }
}

.el-table__fixed-right::before,
.el-table__fixed::before {
  height: 0px;

  @include useTheme {
    background-color: getVar('border-color-base');
  }
}

.el-table--border::after,
.el-table--group::after,
.el-table::before {
  height: 0px;

  @include useTheme {
    background-color: getVar('border-color-base');
  }
}

.el-table__body,
.el-table__footer,
.el-table__header {
  @include useTheme {
    border-collapse: collapse;
  }
}

.el-table__body-wrapper {
  &::-webkit-scrollbar {
    // 纵向滚动条
    width: 10px;
    // 横向滚动条
    height: 10px;
  }

  &::-webkit-scrollbar-thumb {
    // 滚动条滑块颜色
    background-color: rgba($color: #909399, $alpha: 0.3);
    border-radius: 5px;

    &:hover {
      background-color: rgba($color: #909399, $alpha: 0.5);
    }
  }

  &::-webkit-scrollbar-track {
    // 滚动条背景色
    background-color: #ffffff;
    opacity: 0.3;
  }

  &::-webkit-scrollbar-corner {
    // 表格滚动条角落
    background-color: #ffffff;
    opacity: 0.3;
  }
}

.el-input__inner {
  border-radius: 1px;

  @include useTheme {
    color: getVar('text-color');
  }

  &:focus {

    @include useTheme {
      border-color: getVar('primary-color');
      outline: 0;
    }
  }
}

.el-input {
  &.is-active {
    .el-input__inner {
      outline: 0;

      @include useTheme {
        border-color: getVar('primary-color');
      }
    }
  }
}

.el-input.is-disabled .el-input__inner {
  @include useTheme {
    background-color: getVar('background-color');
    border-color: getVar('border-color-base');
    color: getVar('text-color');
    cursor: not-allowed;
  }
}

.el-range-editor.is-active,
.el-range-editor.is-active:hover,
.el-select .el-input.is-focus .el-input__inner {
  @include useTheme {
    border-color: getVar('primary-color');
  }
}

.el-select .el-input.is-disabled .el-input__inner:hover {
  @include useTheme {
    border-color: getVar('primary-color');
  }
}

.el-select:hover .el-input__inner {
  @include useTheme {
    border-color: getVar('primary-color');
  }
}

.el-textarea__inner {
  padding-top: 0;
  padding-bottom: 0;
  line-height: 34px;
}

.el-input__inner {
  @include useTheme {
    background: transparent;
    color: getVar('title-color');
    border-color: getVar('border-color-base');
  }
}

.el-select-dropdown {
  @include useTheme {
    background: getVar('card-background-color');
    color: getVar('title-color');
  }
}

.el-dialog {
  @include useTheme {
    background: getVar('card-background-color');
    border-radius: getVar('border-radius-base');
    color: getVar('title-color');
  }
}

.el-dialog__title {
  @include useTheme {
    color: getVar('title-color');
  }
}

.el-dialog__headerbtn {

  &:focus,
  &:hover {
    .el-dialog__close {
      @include useTheme {
        color: getVar('primary-color');
      }
    }
  }

  .el-dialog__close {
    @include useTheme {
      color: getVar('title-color');
    }
  }
}

.el-dialog__body {
  @include useTheme {
    color: getVar('title-color');
  }
}

.el-form-item__label {
  @include useTheme {
    color: getVar('title-color');
  }
}

$colors: (
        info: getVar('primary-color'),
        success: getVar('success-color'),
        warning: getVar('warning-color'),
        error: getVar('error-color'),
);

.el-message {
  border-radius: 1px;
  min-width: 0;
  padding-right: 25px;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.1);

  @include useTheme {

    @each $key, $value in $colors {
      .el-icon-#{$key} {
        color: $value;
      }
    }
  }
}

@each $key, $value in $colors {
  .el-message--#{$key} {
    @include useTheme {
      border-color: coloren($color: $value, $amount: 36%);
      background-color: coloren($color: $value, $amount: 45%);
    }

    .el-message__content {
      color: $value;
    }
  }
}

.el-card {
  @include useTheme {
    border: 1px solid getVar('border-color-base');
    background-color: getVar('card-background-color');
    color: getVar('text-color');
    border-radius: getVar('border-radius-base');
  }
}

.el-descriptions {
  @include useTheme {
    color: getVar('title-color');
  }
}

.el-descriptions__body {
  @include useTheme {
    color: getVar('text-color');
    background-color: getVar('card-background-color');
  }
}

.el-descriptions-row {
  &:hover {
    @include useTheme {
      color: getVar('primary-color');
    }
  }
}

.el-descriptions-item__label.is-bordered-label {
  @include useTheme {
    font-weight: bold;
    color: getVar('title-color');
    background: getVar('title-background-color');
  }
}

.el-descriptions .is-bordered .el-descriptions-item__cell {
  @include useTheme {
    border: 1px solid getVar('border-color-base');
  }
}

.el-drawer {
  @include useTheme {
    color: getVar('title-color');
    background-color: getVar('card-background-color');
  }
}

.el-drawer__header {
  @include useTheme {
    color: getVar('title-color');
  }
}

.el-tree {
  @include useTheme {
    color: getVar('title-color');
    background-color: getVar('card-background-color');
  }
}

.el-tree-node__content:hover,
.el-upload-list__item:hover {
  @include useTheme {
    background-color: getVar('hover-background-color');
  }
}

.el-tree-node:focus > .el-tree-node__content {
  @include useTheme {
    background-color: getVar('hover-background-color');
  }
}

.el-menu {
  border-right: none;

  @include useTheme {
    background-color: getVar('card-background-color');
  }
}

.el-menu-item {
  transition: border-color .1s, background-color .1s, color .1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  @include useTheme {
    color: getVar('title-color');
  }
}

.el-menu-item.is-active {
  @include useTheme {
    color: getVar('primary-color');
  }
}

.el-menu-item:focus,
.el-menu-item:hover {
  @include useTheme {
    background-color: coloren($color: getVar('primary-color'), $amount: 45%);
  }
}

.el-menu-item i {
  @include useTheme {
    color: getVar('title-color');
  }
}

.el-menu-item.is-active i {
  @include useTheme {
    color: getVar('primary-color');
  }
}

.el-menu-item [class^=el-icon-] {
  @include useTheme {
    width: 28px;
    margin-left: 2px;
    margin-right: 22px;
  }
}

.el-menu--collapse {
  @include useTheme {
    width: 72px;
  }
}

.el-tabs--border-card {
  @include useTheme {
    border: 1px solid getVar('border-color-base');
    box-shadow: none;
    background: getVar('card-background-color');

    &:hover {
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    }
  }
}

.el-tabs--border-card > .el-tabs__header .el-tabs__item.is-active {
  @include useTheme {
    color: getVar('primary-color');
    background-color: getVar('card-background-color');
    border-right-color: getVar('border-color-base');
    border-left-color: getVar('border-color-base');
  }
}

.el-tabs--border-card > .el-tabs__header {
  @include useTheme {
    background-color: getVar('title-background-color');
    border-bottom: 1px solid getVar('border-color-base');
  }
}

.el-tabs--border-card > .el-tabs__header .el-tabs__item {
  @include useTheme {
    color: getVar('title-color');

    &:hover {
      color: getVar('primary-color');
    }
  }
}

.el-tabs--border-card > .el-tabs__content {
  @include useTheme {
    padding: 20px;
  }
}

.el-tag {
  @include useTheme {
    color: getVar('text-color');
    background-color: transparent;
    border-radius: getVar('border-radius-base');
    border-color: getVar('border-color-base');

    &:hover,
    &:focus {
      color: getVar('primary-color');
      border-color: getVar('primary-color');
      background-color: transparent;
    }

    &:active {
      color: color.adjust($color: getVar('primary-color'), $lightness: -12%);
      border-color: color.adjust($color: getVar('primary-color'), $lightness: -12%);
      background-color: transparent;
    }

    $tag-colors: (
            primary: getVar('primary-color'),
            success: getVar('success-color'),
            warning: getVar('warning-color'),
            danger: getVar('error-color'),
            info: getVar('primary-color'),
    );

    @each $key, $value in $tag-colors {
      &.el-tag--#{$key} {
        color: white;
        background-color: $value;
        border-color: $value;
        border-radius: getVar('border-radius-base');

        &:hover,
        &:focus {
          color: white;
          border-color: coloren($color: $value, $amount: 8%);
          background-color: coloren($color: $value, $amount: 8%);
        }

        &:active {
          color: white;
          border-color: color.adjust($color: $value, $lightness: -10%);
          background-color: color.adjust($color: $value, $lightness: -10%);
        }
      }
    }
  }
}

.el-checkbox__input.is-checked .el-checkbox__inner,
.el-checkbox__input.is-indeterminate .el-checkbox__inner {
  @include useTheme {
    background-color: getVar('primary-color');
    border-color: getVar('primary-color');
  }
}

.jv-container.jv-light {
  @include useTheme {
    background-color: getVar('card-background-color');
    color: getVar('text-color');
  }
}

.jv-container.jv-light .jv-key {
  @include useTheme {
    color: getVar('title-color');
  }
}

.jv-container.jv-light .jv-item.jv-object {
  @include useTheme {
    color: getVar('title-color');
  }
}